package com.telecomyt.jwportal.activity.fragment.adapter;

import android.widget.CheckBox;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.bean.UsersBean;

/**
 * @author created by chengDa
 * @time 2020/8/29  10:21
 * @description
 */
public class ContentAdapter extends BaseQuickAdapter<UsersBean.DeptsBean, BaseViewHolder> {
    public ContentAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, UsersBean.DeptsBean item) {
        TextView mTvName = helper.getView(R.id.mTvName);
        if (item.getUserCount() > 0) {
            mTvName.setText(String.format("%s(%s)", item.getDeptName(), item.getUserCount()));
        } else {
            mTvName.setText(item.getDeptName());
        }
        CheckBox mCheckBox = helper.getView(R.id.mCheckBox);
        if (item.isCheck()) {
            mCheckBox.setChecked(true);
        } else {
            mCheckBox.setChecked(false);
        }
        helper.addOnClickListener(R.id.mCheckBox);

    }
}
